package com.example.yjhuser.service.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.yjhuser.entity.Comment;
import com.example.yjhuser.entity.PersonCommentDTO;
import com.example.yjhuser.mapper.CommentMapper;
import com.example.yjhuser.service.CommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {

    @Resource
    CommentMapper commentMapper;
    @Override
    public List<Comment> getAllCommentByIdAndType(String id,String type) {
        return commentMapper.selectAllComment(id,type);
    }

    @Override
    public int setComment(Comment comment) {
        return commentMapper.insert(comment);
    }

    @Override
    public int delComment(String id) {
        QueryWrapper<Comment> wrapper = new QueryWrapper<>();
        wrapper.eq("id",id).or().eq("dj_id",id);
        return  commentMapper.delete(wrapper);
    }

    @Override
    public List<PersonCommentDTO> getAllCommentByUserId(String id) {
        return commentMapper.selectAllCommentByUserId(id);
    }
}
